<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$con = mysqli_connect('localhost', 'root', 'root');
$stmt;

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

mysqli_select_db($con, "vantil");

function prepare($sql){
    global $con, $stmt;
    $stmt = mysqli_prepare($con, $sql);
    echo mysqli_error($con);
}

function print_error(){
    global $stmt, $con;
    
    if (isset ($con))
        echo "Erro conexao: ".mysqli_stmt_error ($con);
    if (isset ($stmt))
        echo "Erro stmt".mysqli_stmt_error ($stmt);
}

function stmt_bind_param($tipo, $valores){
    global $stmt;
    array_unshift($valores, $stmt, $tipo);
    
    call_user_func_array("mysqli_stmt_bind_param", $valores);
}

function stmt_execute(){
    global $stmt;
    return mysqli_stmt_execute($stmt);
}

function stmt_get_result(){
    global $stmt;
    return mysqli_stmt_get_result($stmt);
}

function close_stmt(){
    global $stmt;
    if (isset ($stmt))
        mysqli_stmt_close ($stmt);
}

function close_con(){
    global $con;
    if (isset($con))
        mysqli_close ($con);
}

?>
